home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / IM_Install3.adf / piarc.LZH / renditionwr.rexx < prev    next >
OS/2 REXX Batch file  |  1992-06-22  |  4KB  |  157 lines

  1. /*
  2.  * RenditionWR.rexx
  3.  *
  4.  *  Written by: Pete Patterson
  5.  * Last Update: May 28, 1992
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.0
  9.  */
  10.  
  11. /*
  12.  * open rexxsupport.library -- needed for some functions
  13.  */
  14. if ~show('L',"rexxsupport.library") then do
  15.   if addlib('rexxsupport.library',0,-30,0) then do
  16.       /* everything's ok */
  17.     end;
  18.   else do
  19.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  20.     say 'Cannot operate RenditionRD.rexx without this library - sorry!';
  21.     exit 10;
  22.     end;
  23.   end;
  24.  
  25. /*
  26.  * This will automatically direct the script to the proper
  27.  * software, if it is running.
  28.  */
  29. prtnme = 'IP_Port'; /* assume Image Professional */
  30. if show('P','IP_Port') = 0 then do
  31.   if show('P','IM_Port') = 0 then do
  32.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  33.     say "This script requires IP, IM or IM F/c to run!";
  34.     exit(20);
  35.     end;
  36.   else do
  37.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  38.     end;                 /* We make em, user's break em.          */
  39.   end;
  40.  
  41.   /*
  42.    * This code attempts to read a file called "picmdpath" from REXX:
  43.    * If it can't find it, the script will assume that the commands
  44.    * associated with this PI Module are in "c:". If the file exists,
  45.    * the script will look in the path that is specified in the file.
  46.    * If you create this file, you MUST put a complete, correct path
  47.    * in it; if the commands are in a sub-directory, you have to put
  48.    * the trailing slash on the path (like, device:dir/).
  49.    * 
  50.    */
  51.   cmdpath = 'c:';
  52.   if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  53.     do
  54.       cmdpath = readln(fhandle);
  55.       call close(fhandle);  /* close the file    */
  56.     end
  57.  
  58. options;
  59. address;
  60.  
  61.   prevpath = 'ram:'; /* put user in ram to start with... */
  62.  
  63.   if show('C',rndxpath) = 1 then do
  64.     prevpath = getclip(rndxpath);
  65.     end;
  66.  
  67.   address(prtnme);
  68.   options results;
  69.   'current';
  70.   bufdata = result; /* get name of buffer, if there is one */
  71.   parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum;
  72.   if bname ~= '<none>' then do
  73.     bufname = bname;
  74.     end;
  75.   'filerequest "'||prevpath||'","'||bufname||'","","Save Rendition"';
  76.   rndxfile = result;
  77.   options;
  78.  
  79.   if rndxfile = 'FR_CANCELLED' then do
  80.     address(prtnme);
  81.     'imtofront';
  82.     exit 0;
  83.     end;
  84.  
  85.   rndxfile = expandfilename(rndxfile);
  86.   thispath = gimmepath(rndxfile);
  87.   call setclip(rndxpath,thispath);
  88.  
  89.   address(prtnme);
  90.   options results;
  91.   'jackin';
  92.   jackadr = result;
  93.   options;
  94.  
  95.   'wbtofront';
  96.   'lockimage '||bnum;
  97.   address command cmdpath||'RenditionWR '||jackadr||' "'||rndxfile||'"';
  98.   'unlockimage '||bnum;
  99.  
  100.   address(prtnme);
  101.   'imtofront';
  102.   address;
  103.  
  104.   exit 0;
  105.  
  106. /*
  107.  * gimmepath
  108.  *
  109.  * This takes the provided argument and sucks the path out of it, then
  110.  * returns that path to the caller, sans file name.
  111.  */
  112. gimmepath:
  113.   arg fullnamegx;
  114.     tempgx = reverse(fullnamegx);
  115.     lengx = length(fullnamegx);   /* get length of string */
  116.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  117.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  118.     seploc = 0; /* assumes current dir, no path supplied */
  119.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  120.       seploc = (lengx - slashdex)+1;
  121.       end;
  122.     else do
  123.       if colondex ~= 0 then do /* we assume we are on a device */
  124.         seploc = (lengx - colondex)+1;
  125.         end;
  126.       end;
  127.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  128.   gxpath = left(fullnamegx,seploc);
  129.   return(gxpath);
  130.  
  131. /*
  132.  * Since this script can't be expected to know where the CD of the user
  133.  * is when this cmd is invoked, we have to check the path the user
  134.  * provides - if it's not specified right from a root, then we have
  135.  * to make it a complete specification from the root.
  136.  */
  137. expandfilename:
  138.   parse arg jfile;
  139.   if index(jfile,':') = 0 then do
  140.     curdir = pragma(D);
  141.     if right(curdir,1) ~= ':' then do
  142.       if right(curdir,1) ~= '/' then do
  143.         if curdir ~= '' then do
  144.           curdir = curdir || '/';
  145.           end;
  146.         end;
  147.       end;
  148.     jfile = curdir||jfile;
  149.     end;
  150.   return(jfile);
  151.  
  152. rvalue:
  153.   wordnum = c2d(readch(fhandle,1)) * 256;
  154.   wordnum = wordnum + c2d(readch(fhandle,1));
  155.   return wordnum;
  156.  
  157.